<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: green;
            display: none;
        }
    </style>
</head>
<body>
    <div class="box">这个是流氓广告</div>
</body>
<script>
    var box = document.querySelector('.box');
    var isVisible = false;
    // setInterval 设置定时器每隔一秒就会执行一次函数
    setInterval(function(){
        if(isVisible){
            box.style.display='none';
        }else{
            box.style.display='inline-block';
        }
        isVisible=!isVisible;
    },1000);
</script>
</html>